﻿using System;
using System.Collections.Generic;
using System.Hyper.Process;
using System.Linq;
using System.Text;
using Wyn.PMS.Common.Utils;
using Wyn.PMS.Entity.Entities;

namespace Wyn.PMS.Test.Cache
{
    class OtherCommonTest
    {
        public static void Test()
        {
            
            /*
            RoomOccupy ro = new RoomOccupy();

            ro.HotelID = "11111";

            Type type = ro.GetType();

            foreach (var t in type.GetProperties())
            {
                var attValue = t.GetValue(ro, null);

                Console.WriteLine("属性名{0}值{1}", t.Name, attValue);

                

            }
             
             var xx = typeof(RoomOccupy).Attributes;
            
            */
            

            //string value = DateTime.Today.AddMonths(-1).ToString();

            //double once = 1.00;

            //double twice = 2.00;

            //decimal value = Math.Round((decimal)(((2 / once + 5 / once + 8 / once + 9 / once + 11 / once+ 21 / twice) / 32) * 100), 2);


            //var value=Math.Round((decimal)((32 / (double)9) * 100), 2);

            //Console.WriteLine(value);

            //var billNo = "12345";

            //var kongge = "           ";

            //var add = 8 - billNo.Length;

            //var xxx = billNo.PadRight(8,'x');

            //Console.WriteLine(xxx + "标记");

            //Console.WriteLine("12345678标记");

            //StringBuilder sb = new StringBuilder();

            //sb.Append(billNo.PadRight(8));

            //sb.ToString();

            //string key = "EXTEDX01";
            
            //Console.WriteLine(IsSpecialToken(key)?"是特殊账号":"不是特殊账号");

            //string key1 = "EXTEDX0";

            //Console.WriteLine(IsSpecialToken(key1) ? "是特殊账号" : "不是特殊账号");

            //string key2 = "EXTEDY";

            //Console.WriteLine(IsSpecialToken(key2) ? "是特殊账号" : "不是特殊账号");

            //string key3 = "EXTEDZ1";

            //Console.WriteLine(IsSpecialToken(key3) ? "是特殊账号" : "不是特殊账号");

            TestMath();

            string zz = null;

            var world = ( !string.IsNullOrEmpty(zz) && zz.Length>10)?zz.Substring(0, 10):zz;

            Console.WriteLine(world);

            Console.ReadKey();
        }

        public static bool IsSpecialToken(string key)
        {
            if (key.Length < 7) return false;

            if (SpecialKeys().Contains(key.Substring(0, 7)))
            {
                return true;
            }

            return false;
        }

        private static void TestMath()
        {
            string readCode = string.Empty;

            while (!string.Equals(readCode, "Y"))
            {
                Console.BackgroundColor = ConsoleColor.Blue;

                Console.ForegroundColor = ConsoleColor.Gray;

                Console.Clear();

                Console.Write("\n\r ^_^,请输入值:");

                string input = Console.ReadLine();

                int max = int.Parse(input);

                int dbRooms = 1;

                var value = 1;
                Console.ForegroundColor = ConsoleColor.Green;

                Console.Write("\n\r ^_^,退出测试吗?(Y/N):");

                readCode = Console.ReadKey().KeyChar.ToString().ToUpper();
            }
        }


        public static IList<string> SpecialKeys()
        {
            return new List<string>()
                       {
                           "EXTEDX0",
                           "EXTEDY0",
                           "EXTEDZ0",
                           "EXTEDZ1",
                       };
        }

        
    }
}
